{template 'public/header'}

{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcsslist.css">
<style type="text/css">
    .storespan2 {
        font-size: 14px;
        color: white;
        margin: 5px;
        position: relative;
        background-color: #444444;
    }

    .storespan2:hover {
        color: #fff;
    }

    .storespan2:hover .bianji {
        display: block;
    }

    .feileibq2 > img {
        width: 25px;
        height: 25px;
    }
</style>
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li class="active"><a>管理员列表</a></li>
    <li><a href="{php echo $this->createWebUrl('branchslist');}"><i class="fa fa-refresh"></i>返回门店列表</a></li>
</ul>
<div class="row ygrow">
    <div class="col-lg-12">
        <form action="" method="get" class="col-md-4">
            <input type="hidden" name="c" value="site"/>
            <input type="hidden" name="a" value="entry"/>
            <input type="hidden" name="m" value="yzzc_sun"/>
            <input type="hidden" name="do" value="branchadminlist"/>
            <input type="hidden" name="bid" value="{$bid} "/>
            <div class="input-group">
                <input type="text" name="keywords" class="form-control" placeholder="请输入管理员ID" value="{$op}">
                <span class="input-group-btn">
                  <input type="submit" class="btn btn-default" name="submit" value="查找"/>
                </span>
            </div>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </form>
    </div><!-- /.col-lg-6 -->
</div>
<div class="main">
    <div class="panel-heading wyheader">
        <a href="{php echo $this->createWebUrl('addbranchadmin',array('bid'=>$bid))}" class="storespan2 btn btn-xs">
            <span class="fa fa-plus"></span>添加管理员
            <span class="bianji" style="left: 15px;">添加管理员
                        <span class="arrowdown"></span>
                    </span>
        </a>
        <!--<div class="panel-body ygbtn">-->
        <div class="btn storegrey2" id="allselect">批量删除</div>
        <!--</div>-->
    </div>

    <div class="panel panel-default">
        <div class="panel-heading">
            管理员列表
        </div>
        <div class="panel-body" style="padding: 0px 15px;">
            <div class="row">
                <table class="yg5_tabel col-md-12">
                    <tr class="yg5_tr1">
                        <td class="store_td1 col-md-1" style="text-align: center;">
                            <input type="checkbox" class="allcheck"/>
                            <span class="store_inp">全选</span>
                        </td>
                        <!--<td class="store_td1 col-md-1">编号</td>-->
                        <td class="col-md-1">管理员昵称（ID）</td>
                        <td class="col-md-1">管理员权限</td>
                        <td class="col-md-1">添加时间</td>
                        <td class="col-md-2">操作</td>
                    </tr>
                    {loop $info $key $item}
                    <tr class="yg5_tr2">
                        <td>
                            <input type="checkbox" name="test" value="{$item['id']}">
                        </td>
                        <!--<td>{$item['id']}</td>-->
                        <td>{$item['username']} （{$item['uid']}）</td>
                        <td>{if $item['auth']==1}超级管理员 {else}核销员{/if}</td>
                        <td>{$item['createtime']}</td>
                        <td>
                            <!--<a href="{php echo $this->createWebUrl('addbranchadmin',array('id'=>$item['id'],'bid'=>$item['bid']));}"-->
                               <!--class="storespan btn btn-xs">-->
                                <!--<span class="fa fa-pencil"></span>-->
                                <!--<span class="bianji">编辑-->
                                    <!--<span class="arrowdown"></span>-->
                                <!--</span>-->
                            <!--</a>-->
                            <a href="javascript:void(0);" class="storespan btn btn-xs" data-toggle="modal"
                               data-target="#myModal{$item['id']}">
                                <span class="fa fa-trash-o"></span>
                                <span class="bianji">删除
                                    <span class="arrowdown"></span>
                                </span>
                            </a>
                        </td>

                    </tr>
                    <div class="modal fade" id="myModal{$item['id']}" tabindex="-1" role="dialog"
                         aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                            aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                                </div>
                                <div class="modal-body" style="font-size: 20px">
                                    确定删除么？
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                    <a href="{php echo $this->createWebUrl('branchadminlist', array('op' => 'delete', 'id' => $item['id'],'bid'=>$item['bid']))}"
                                       type="button" class="btn btn-info">确定</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    {/loop}
                    {if empty($info)}
                    <tr class="yg5_tr2">
                        <td colspan="8">
                            暂无信息
                        </td>
                    </tr>
                    {/if}
                </table>
            </div>
        </div>
    </div>

</div>
<div class="text-right we7-margin-top">
    {$pager}
</div>
<script type="text/javascript">
    $(function () {
        $("#frame-1").show();
        $("#yframe-1").addClass("wyactive");
        // ———————————————批量删除———————————————
        $("#allselect").on('click', function () {
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            var bid=$("input[name='bid']").val();
            if (check.length < 1) {
                alert('请选择要删除的管理员!');
                return false;
            } else if (confirm("确认要删除此管理员?")) {
                var id = new Array();
                check.each(function (i) {
                    id[i] = $(this).val();
                });
                console.log(id);
                $.ajax({
                    type: "post",
                    url: "{php echo $this->createWebUrl('branchadminlist',array('op'=>'delete'))}",
                    dataType: "text",
                    data: {id: id,bid:bid},
                    success: function (data) {
                        console.log(data);
                        location.reload();
                    }
                })

            }
        });

        $(".allcheck").on('click', function () {
            var checked = $(this).get(0).checked;
            $("input[type=checkbox]").prop("checked", checked);
        });
    })
</script>